<template>
  <div>
    <el-card>
    <el-form ref="form" :model="formData" size="medium" label-width="110px">
      <el-row>
        <el-col :span="6">
          <el-row>
            <el-form-item label="oid" prop="orgId" v-show="false">
              <el-input :model="formData.orgId" clearable :style="{width: '90%'}"></el-input>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="年份" prop="yearly">
<!--                              <el-date-picker :model="formData.yearly" type="year" placeholder="选择年份" format="yyyy" value-format="yyyy"-->
<!--                                              :style="{width: '65%'}" clearable></el-date-picker>-->
              <!--                <el-select v-model="formData.yearly" filterable placeholder="请选择">-->
              <!--                  <el-option-->
              <!--                    v-for="item in year"-->
              <!--                    :key="item.value"-->
              <!--                    :label="item.label"-->
              <!--                    :value="item.value">-->
              <!--                  </el-option>-->
              <!--                </el-select>-->
              <el-select v-model="formData.yearly" placeholder="请选择">
                <el-option
                  v-for="item in year"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-row>
        </el-col>
        <el-col :span="9">
          <el-row>
            <el-form-item label-width="150px" label="人员经费（万元）" prop="preFund">
              <el-input v-model="formData.preFund" clearable :style="{width: '90%'}"></el-input>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label-width="150px" label="业务经费（万元）" prop="businessFund">
              <el-input v-model="formData.businessFund" clearable :style="{width: '90%'}"></el-input>
            </el-form-item>
          </el-row>
        </el-col>
        <el-col :span="9">
          <el-row>
            <el-form-item label-width="160px" label="公务费（万元）" prop="dutyFund">
              <el-input v-model="formData.dutyFund" clearable :style="{width: '90%'}"></el-input>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label-width="160px" label="基本建设资金（万元）" prop="buildFund">
              <el-input v-model="formData.buildFund" clearable :style="{width: '90%'}"></el-input>
            </el-form-item>
          </el-row>
        </el-col>
      </el-row>
      <el-row justify="center">
        <el-button type="success" @click="preserve">保存</el-button>
        <el-button type="info" @click="back">返回</el-button>
      </el-row>
    </el-form>
    </el-card>
  </div>
</template>

<script>
  import {post} from "@/utils/api";
  export default {
    data() {
      return {
        formData:{},
        dialogVisible:false,
        year:[],

      }
    },
    created(){
      this.formData.orgId = this.$route.query.id
      //console.log(this.orgId)
      console.log("----1-------1--------"+this.formData.orgId)
      for(let i=2023;i>2010;i--){
        let obj = {}
        obj.id = i
        obj.name = i
        this.year.push(obj)
      }
      // console.log(this.year)
    },
    // watch:{
    //   orgid:{
    //     handler(newval,oldval){
    //       this.getbymoney()
    //     },
    //     immediate:true
    //   }
    // },
    methods:{
      // //修改完的确认
      // handlesure(){
      //   this.dialogVisible = false
      //   this.$router.go(-1)
      // },
      // //money的修改
      // async handleupdate(){
      //   let res = await post("money/getbyidupdate",{...this.formData})
      //   console.log("-----"+res);
      //   // this.dialogVisible=true
      //   alert("提交成功")
      // },
      // //按ID查询
      // async getbymoney(){
      //   console.log(this.orgid)
      //   let res = await post("money/getbyid", {id:this.orgid})
      //   console.log("------222222222222------")
      //   console.log(res)
      //   this.formData = res
      // },
      //机构财政拨款的添加
      async preserve(){
        if(Object.keys(this.formData)==0)
          alert("请输入数据")
        else{
          let res = await post("money/add",this.formData)
          console.log(res)
        }

      },
      //返回上一页
      back(){
        this.$router.go(-1)
      },
    },

  }
</script>
<style></style>
